package logic

import (
	"context"
	"fmt"
	"order_srv/model/mysql"

	"order_srv/internal/svc"
	"order_srv/order"

	"github.com/zeromicro/go-zero/core/logx"
)

type CreateOrderAddressLogic struct {
	ctx    context.Context
	svcCtx *svc.ServiceContext
	logx.Logger
}

func NewCreateOrderAddressLogic(ctx context.Context, svcCtx *svc.ServiceContext) *CreateOrderAddressLogic {
	return &CreateOrderAddressLogic{
		ctx:    ctx,
		svcCtx: svcCtx,
		Logger: logx.WithContext(ctx),
	}
}

func (l *CreateOrderAddressLogic) CreateOrderAddress(in *order.CreateOrderAddressRequest) (*order.CreateOrderAddressResponse, error) {
	// todo: add your logic here and delete this line
	address := mysql.OrderAddress{
		OrderId:  in.OrderId,
		Province: in.Province,
		City:     in.City,
		Area:     in.Area,
		Address:  in.Address,
		Mobile:   in.Mobile,
		Name:     in.Name,
	}
	err := address.CreateAddress()
	if err != nil {
		fmt.Println("")
		return nil, err
	}
	return &order.CreateOrderAddressResponse{}, nil
}
